package com.haoan.index.utils.wx;

/**
 * @Auther: Kai
 * @Date: 2024/8/28
 * @Description: com.haoan.utils.alipay
 */
public enum WxpayTradeStatusEnum {
    SUCCESS("SUCCESS", "支付成功"),
    REFUND("REFUND", "转入退款"),
    NOTPAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销（仅付款码支付会返回）"),
    USERPAYING("USERPAYING", "用户支付中（仅付款码支付会返回）"),
    PAYERROR("PAYERROR", "支付失败（仅付款码支付会返回）"),
    UNKNOW("", "未知的状态");

    private String code;
    private String name;

    WxpayTradeStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WxpayTradeStatusEnum getByCode(String code) {
        for (WxpayTradeStatusEnum tradeStatusEnum : WxpayTradeStatusEnum.values()) {
            if (tradeStatusEnum.getCode().equals(code)) {
                return tradeStatusEnum;
            }
        }
        return UNKNOW;
    }
}